Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v3 without conan #496

Merged
merged 74 commits into from
Aug 16, 2023
Merged

v3 without conan #496

merged 74 commits into from
Aug 16, 2023

Conversation

rturrado
Copy link
Contributor

@rturrado rturrado commented Aug 2, 2023

CMake

Updated C++ version to C++23.
Updated GitHub Actions to build in gcc/clang/msvc x Linux/MacOS/Windows x Debug/Release.
Updated dependency management to be done through FetchContent instead of git submodules.

  • CMake minimum required version is now 3.25, due to FetchContent_Declare(... SYSTEM).
  • lemon dependency is now fetched through a fork, which fixes C++17 & 20 compilation, and some CMake and C++ warnings.

Reorganized tests, examples, and resources.

Reorganized tests.

  • All tests are now under the test folder.
  • All tests are googletest. doctest dependency has been removed.
  • All tests are discovered. CMake code for adding tests has been removed.
  • Python tests have been updated to comply to most of PEP 8 (code style guide).

Reorganized resources.

  • All resources are now under the res folder.
  • Some file names were changed.

Reorganized examples.

  • All example codes are now under example folders within test.
  • All example resources are now under example folders within res.

The structure of the test folder is:

  |- ql
  |  \- com, ir, pass, utils...
  \- v1x
     |- cpp
     |  \- example
     \- python
        |- example
        \- visualizer

The structure of the res/v1x folder is:

  |- cq
  |  |- example
  |  \- golden
  |- json
  |  \- visualizer
  \- qasm
     \- golden

v1x stands for cQasm v1.x. There may be folders such as v3x in the future.

File changes

  • deps: removed.
  • docs:
    • Changed from openql import openql as ql to import openql as ql.
    • Changed nqubits to num_qubits.
  • include/ql, source/ql:
    • Fixed warnings and compilation errors.
    • Update references to resources to point to the new location in res.
  • python/ql.i: minor aesthetic change: split a very whole string into different lines.
  • .gitmodules: removed.
  • CMakeLists.txt: C++23, FetchContent, ql target_compile_options.
  • pytest.ini: updated testpaths to point to test/v1x/python.

rturrado and others added 30 commits April 22, 2023 22:47
Added a possible test folder structure.
Added an empty test/ql/ir/cqasm/read.cc test file.
read.cc: moved parse code to a separate function, which is the one that is being tested.
- renamed 'read' as read_v1 and added read_v3.
src/ql/ir/cqasm/read.cc:
- 'read' now parses the program version and calls whether read_v1 or read_v3.
- read_v3 still doesn't do anything.
test/ql/ir/cqasm/read.cc:
- commented out tests for versions older than 1.2 as they need an IR with just more than a 'version' statement.
- tests now create an IR and a basic platform and call 'read', passing a very simple program that only has a 'version' statement.
… being PlatformFake. Now the test is simplified a bit.
Added OpenQL/v3 to GitHub Actions.
This change makes some of the git submodules to stop working, since they are not C++20 compliant.
That doesn't mean we can not still use their binaries.
Updated GitHub workflow's cpp job to use Conan.
Updated README file.

.gitmodules, CMakeLists.txt, conanfile.py:
- Removed all git submodules.
- Added backward-cpp, cimg, eigen, highs, nlohmann_json, doctest and gtest as Conan dependencies.
- libqasm and lemon are now obtained via FetchContent, since there are not yet Conan packages for them.
- lemon is patched after download to fix C++17 and C++20 compilation warnings.

circuit.h/cc, functions.h/cc, gate.h, list.h, mappings.h, old_to_new.cc, past.cc, prim.h, types.h, unitary.cc, vec.h: fixed C++20 compilation warnings and errors.
TODO: organize tests in OpenQL as we did for libqasm.
Updated setup.py so that it calls Conan instead of CMake.
Added a new patch for lemon.
Removed highs from .gitmodules.
… anyway, and 2) and most importantly, since libqasm is fetched via FetchContent, it will require flex/bison/m4/tree-gen for its compilation.

conanfile.py: added flex/bison/m4 as dependencies to conanfile.py.
test.yml: commented out everything except for C++ Windows builds.
C++20 adds a 'synthesized' y==x for each x==y, what can lead to ambiguities in existing C++17 code.
In our case, many of these operator== implementations come from code generated by tree-gen.
A possible solution would be to add friend operator== functions to resolve the ambiguities.
A probably less elegant solution, that is what I've done here, and that avoids touching the code generated by tree-gen, is to use the x.operator==(y) syntax in the caller side.
I've finally added a non-member operator==(const Object &, const PhysicalObject &) to resolve the code ambiguities due to moving to C++20:
- We leave all the existing code untouched, and using the simpler syntax 'x == y' instead of 'x.operator==(y)'.
- We don't change anything either in ir.tree (e.g. adding the non-member function there as a friend to PhysicalObject, for example).
- We simply add the function in 'ir_gen_ex.cc' (read it as an extension to ir.gen.cc, the file generated by tree-gen).
test.yml: going to test only macos for the moment.
Testing C++23 Ubuntu/MacOS/Windows compilation.
…rator==(const Object&, const PhysicalObject&).
…rator==(const Link<Object>&, const Link<PhysicalObjec>t&).
…perator==(const Link<Object>&, const Link<PhysicalObjec>t&).
CMakeLists.txt: added a debug comment to the patch_lemon_sources_command.
test.yml: testing only MacOS.
rturrado added 10 commits July 28, 2023 10:32
- Temporarily commented out 'add_subdirectory(test)'.
- Minor aesthetic changes to the FetchContent sections.
test.yml:
- Removed OPENQL_BUILD_CPP_STANDALONE_EXAMPLE option, and 'example' execution from all the jbs.
- Changed '$env::GITHUB_ENV' to '$GITHUB_ENV' for Python Windows builds.
CMakeLists.txt:
- 'add_subdirectory(test)' commented in again.
test.yml:
- Changed number of parallel build processes from 10 to 5.
- Changed '$GITHUB_ENV' back to '$env:GIHTUB_ENV' for Python Windows builds.
- All tests are now under the 'test' folder.
- All tests are googletest. doctest dependency has been removed.
- All tests are discovered. CMake code for adding tests has been removed.
- Python tests have been updated to comply to most of PEP 8 (code style guide).

Reorganized resources.
- All resources are now under the 'res' folder.

Reorganized examples.
- All example codes are now under 'example' folders within 'test'.
- All example resources are now under 'example' folders within 'res'.

The structure of the 'test' folder is:
  |- ql
  |  \- com, ir, pass, utils...
  |- v1x
  |  |- cpp
  |  |  \- example
  |  |- python
  |     |- example
  |     \- visualizer

The structure of the 'res/v1x' folder is:
  |- cq
  |  |- example
  |  \- golden
  |- json
  |  \- visualizer
  |- qasm
     \- golden

'v1x' stands for cQasm v1.x. There may be folders such as 'v3x' in the future.
…cludes all the libqasm/v3 work.

Updated v1 references to v1x.
# Conflicts:
#	.github/workflows/test.yml
#	include/ql/ir/compat/gate.h
#	res/v1x/json/debug.cc
#	res/v1x/json/test_cfg_none_simple.json
#	res/v1x/json/test_multi_core_64x16_full.json
#	res/v1x/json/test_unitary.cc
#	res/v1x/qasm/golden/test_condex_toffoli_compos_gate_last.qasm
#	res/v1x/qasm/golden/test_mc_non_comms_last.qasm
#	res/v1x/qasm/test_gate_decomposition_cz.cc_backend.map
#	res/v1x/qasm/test_gate_decomposition_cz.cc_backend.vcd
#	res/v1x/qasm/test_gate_decomposition_cz.cc_backend.vq1asm
#	res/v1x/qasm/test_gate_decomposition_cz.initial.cq
#	res/v1x/qasm/test_gate_decomposition_cz.scheduled.cq
#	res/v1x/qasm/test_qi_example.cc_backend.map
#	res/v1x/qasm/test_qi_example.cc_backend.vcd
#	res/v1x/qasm/test_qi_example.cc_backend.vq1asm
#	res/v1x/qasm/test_qi_example.initial.cq
#	res/v1x/qasm/test_qi_example.scheduled.cq
#	src/ql/arch/cc/pass/gen/vq1asm/detail/backend.cc
#	src/ql/arch/cc/pass/gen/vq1asm/detail/functions.cc
#	src/ql/ir/new_to_old.cc
#	src/ql/pass/ana/visualize/detail/types.h
#	src/ql/pass/map/qubits/map/detail/alter.cc
#	src/ql/pass/map/qubits/map/detail/free_cycle.cc
#	src/ql/pass/map/qubits/map/detail/mapper.cc
#	src/ql/pass/map/qubits/map/detail/past.cc
#	src/ql/pass/map/qubits/place_mip/place_mip.cc
#	tests/CMakeLists.txt
#	tests/test_mapper.py
#	tests/test_unitary.py
@rturrado rturrado requested a review from pablolh August 2, 2023 09:33
rturrado added 11 commits August 2, 2023 12:31
README.md: removed Dependencies and Installation sections (reverted PR changes).
include/ql/ir/cqasm: removed '#include "cqasm.hpp"', and 'read_v3' function declaration.
test.yml: added 'on/push/pull_request'.
tests: removed.
… 'write_model_to_file' to true by default.

The IpGridTest.grid__find_complex_permutation ends up calling Impl::run and writing an 'LpMatrix.pbm' file to the root directory.

We have changed it to write the file to the temporary directory instead.

Another option would be not to write out any file during testing.
…l.h sets 'write_model_to_file' to true by default."

This reverts commit 23f2d1c.
Renaming of some resource files.
.github/workflows/test.yml Outdated Show resolved Hide resolved
.github/workflows/test.yml Show resolved Hide resolved
README.md Show resolved Hide resolved
setup.py Show resolved Hide resolved
src/ql/ir/compat/detail/cqasm_reader.h Outdated Show resolved Hide resolved
src/ql/utils/vcd.cc Show resolved Hide resolved
test/ql/com/ddg/ddg.cc Show resolved Hide resolved
test/v1x/cpp/example/cpp_standalone.cc Outdated Show resolved Hide resolved
@pablolh
Copy link
Contributor

pablolh commented Aug 10, 2023

few comments I think this can be merged quickly!

test.yml: removed 'fetch-depth: 0' and moved 'checkout' stop after installation steps and right before creation of the build directory.
assets.yml:
- Updated 'checkout' step to not use 'recursive'.
- Updated GitHub Actions versions.
- Changed manylinux job's 'Install cmake' step to use 'Get latest CMake', as in other jobs.
- Removed dependency to Python 3.7.
- Removed commented code.
src/*.cc: added back in the names of the unused parameters, although commmented out.
cpp_standalone.cc: changed into a test.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants